﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Fotobanka
{
    public partial class Registrace : System.Web.UI.Page
    {
        UserManager um;
        protected void Page_Load(object sender, EventArgs e)
        {
            um = new UserManager();
        }

        protected void regButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                um.InsertTodb(email.Text, jmeno.Text, prijmeni.Text, telefon.Text, heslo.Text, spravcovstvi.Checked, false, mobil.Text, Convert.ToInt32((icq.Text.Trim() == "")? "0" : icq.Text), skype.Text);
                Response.Redirect("Registrace_ok.aspx");
            }
        }

        protected void emailExistValidator_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (um.EmailAlreadyExist(email.Text))
                args.IsValid = false;
            else
                args.IsValid = true;
        }

    }
}
